﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuanLyNhaSach.DataAccessLayer
{
    public class PhieuNhapDAO
    {
        DataConnection dt_con = new DataConnection();
        public PhieuNhapDAO()
        {

        }
        public DataTable LayDanhSach()
        {
            return dt_con.Read("select * from PHIEUNHAP");
        }

        public void ThemPhieuNhap(string maPhieuNhap, string ngayNhap)
        {
            string cmd = "exec PHIEUNHAP_insert '{0}','{1}'";
            dt_con.Write(String.Format(cmd, maPhieuNhap, ngayNhap));
        }

        public void ThemCTN(string maPhieuNhap, string maSach, string soLuong, string donGia)
        {
            string cmd = "exec CTNS_insert '{0}', '{1}', {2}, {3}";
            dt_con.Write(String.Format(cmd, maPhieuNhap, maSach, soLuong, donGia));
        }

        public DataTable LayTheoThang(string datatime)
        {
            return dt_con.Read("exec PHIEUNHAP_GetforMonth '" + datatime+"'");
        }

        public DataTable LayPhieuNhap(string date)
        {
            return dt_con.Read("exec PHIEUNHAP_GetforMonth '" + date + "'");
        }
    }
}
